package com.ruoyi.yuce.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yuce.domain.Bujiancanshu;
import com.ruoyi.yuce.service.IBujiancanshuService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 部件参数Controller
 *
 * @author xinhui
 * @date 2023-01-17
 */
@RestController
@RequestMapping("/ruoyi-yuce/bujiancanshu")
@DataSource(value = DataSourceType.SLAVE)
public class BujiancanshuController extends BaseController
{
    @Autowired
    private IBujiancanshuService bujiancanshuService;

    /**
     * 查询部件参数列表
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-yuce:bujiancanshu:list')")
    @GetMapping("/list")
    public TableDataInfo list(Bujiancanshu bujiancanshu)
    {
        startPage();
        List<Bujiancanshu> list = bujiancanshuService.selectBujiancanshuList(bujiancanshu);
        return getDataTable(list);
    }

    /**
     * 导出部件参数列表
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-yuce:bujiancanshu:export')")
    @Log(title = "部件参数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Bujiancanshu bujiancanshu)
    {
        List<Bujiancanshu> list = bujiancanshuService.selectBujiancanshuList(bujiancanshu);
        ExcelUtil<Bujiancanshu> util = new ExcelUtil<Bujiancanshu>(Bujiancanshu.class);
        util.exportExcel(response, list, "部件参数数据");
    }

    /**
     * 获取部件参数详细信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-yuce:bujiancanshu:query')")
    @GetMapping(value = "/{bjlxid}")
    public AjaxResult getInfo(@PathVariable("bjlxid") Integer bjlxid)
    {
        return success(bujiancanshuService.selectBujiancanshuByBjlxid(bjlxid));
    }

    /**
     * 新增部件参数
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-yuce:bujiancanshu:add')")
    @Log(title = "部件参数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Bujiancanshu bujiancanshu)
    {
        return toAjax(bujiancanshuService.insertBujiancanshu(bujiancanshu));
    }

    /**
     * 修改部件参数
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-yuce:bujiancanshu:edit')")
    @Log(title = "部件参数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Bujiancanshu bujiancanshu)
    {
        return toAjax(bujiancanshuService.updateBujiancanshu(bujiancanshu));
    }

    /**
     * 删除部件参数
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-yuce:bujiancanshu:remove')")
    @Log(title = "部件参数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bjlxids}")
    public AjaxResult remove(@PathVariable Integer[] bjlxids)
    {
        return toAjax(bujiancanshuService.deleteBujiancanshuByBjlxids(bjlxids));
    }
}
